//
//  ChooseQuViewController.m
//  u76ho
//
//  Created by m-air-01 on 16/2/21.
//  Copyright © 2016年 LV. All rights reserved.
//

#import "ChooseQuViewController.h"
#import "PositionModel.h"
#import "MineFirCell.h"
#import "CreateResumeVC.h"
#import "StartYQViewController.h"
@interface ChooseQuViewController ()
<UITableViewDataSource,UITableViewDelegate>
{
    UITableView * _tableView;
    NSMutableArray * dataSource;
}
@end

@implementation ChooseQuViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self main];
   // [self addBackItem];
    
    self.navigationItem.title = _titleStr;
   // [self addNavgationBar];
    
    // Do any additional setup after loading the view.
}
-(void)main
{
    dataSource = [[NSMutableArray alloc]init];
    self.view.backgroundColor = [UIColor whiteColor];
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT-64) style:UITableViewStylePlain];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    [_tableView registerNib:[UINib nibWithNibName:@"MineFirCell" bundle:nil] forCellReuseIdentifier:@"MineFirCell"];
    
    [self.view addSubview:_tableView];
    self.automaticallyAdjustsScrollViewInsets = NO;
    _tableView.backgroundColor = UIColorFromRGB(0xf1f3f2);
    [self requestData];
}
-(void)requestData
{
    [U76HONet selectedTypeReadWithtype:@"1" fid:_fid code:_code andDataBlock:^(NSArray *arr) {
        NSLog(@"区市分类获取成功了");
        [dataSource addObjectsFromArray:arr];
        [_tableView reloadData];
    }];
    
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return dataSource.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MineFirCell * cell = [tableView dequeueReusableCellWithIdentifier:@"MineFirCell"];
    PositionModel * model = dataSource[indexPath.row];
    cell.contentLab.text = model.typenames;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.isHidden = @"yes";
    return cell;
    
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    PositionModel * model = dataSource[indexPath.row];
    NSDictionary * dic = @{@"ids":model.Ids,@"tag":[NSNumber numberWithInt:_tag],@"typenames":model.allname};
    [[NSNotificationCenter defaultCenter] postNotificationName:@"choosePSQNoti" object:dic];
    
    for (UIViewController *temp in self.navigationController.viewControllers) {
        if ([temp isKindOfClass:[CreateResumeVC class]]) {
            [self.navigationController popToViewController:temp animated:YES];
        }
    }
    
    for (UIViewController *temp in self.navigationController.viewControllers) {
        if ([temp isKindOfClass:[StartYQViewController class]]) {
            [self.navigationController popToViewController:temp animated:YES];
        }
    }
    
}
#pragma  mark - 返回按钮图标
-(void)addBackItem{
    UIButton * backItem = [UIButton buttonWithType:UIButtonTypeCustom];
    backItem.frame = CGRectMake(0, 0, 9, 17);
    [backItem setImage:[UIImage imageNamed:@"返回图标"] forState:UIControlStateNormal];
    [backItem addTarget:self action:@selector(backItem:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backItem];
}
-(void)backItem:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
